﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsTamUngNhaCungCapChiTiet
    {
        private string mDienGiaiAnh = "";
        private string mDienGiaiViet = "";
        private string mKhoa = "";
        private string mKhoaDoiTuongCo = "";
        private string mKhoaDoiTuongNo = "";
        private string mKhoaDonVi = "";
        private string mKhoaLoaiTien = "";
        private string mKhoaTaiKhoanCo = "";
        private string mKhoaTaiKhoanNo = "";
        private string mKhoaTamUng = "";
        private string mNgayChungTu = "";
        private string mSoChungTu = "";
        private double mSoTien = 0.0;
        private double mSoTienGhiSo = 0.0;
        private double mSoTienThuc = 0.0;
        private double mSoTienThucGhiSo = 0.0;
        private double mTyGia = 0.0;

        public bool DelData(string pKhoa)
        {
            IDataParameter parameter = null;
            bool flag=false;
            string commandText = "";
            try
            {
                commandText = "DELETE FROM GL_TamUngNhaCungCapChiTiet WHERE KhoaTamUng = '" + pKhoa.Trim() + "'";
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }) > 0;
                flag = flag2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetListTamUngNhaCungCapChiTiet(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = "select TUCT.KHOA, TUCT.KHOATAMUNG, TUCT.SOCHUNGTU, TUCT.NGAYCHUNGTU, DMTK.KHOA KHOATK, DMTK.SOTAIKHOAN, DMLT.MA, DMLT.TENVIET TENLOAITIEN, TUCT.TYGIA, TUCT.SOTIEN, TUCT.SOTIENGHISO, TUCT.SOTIENTHUC, TUCT.SOTIENTHUCGHISO, TUCT.DIENGIAIVIET, TUCT.DIENGIAIANH from GL_TamUngNhaCungCapChiTiet TUCT left join DM_TAIKHOAN DMTK on TUCT.KHOATAIKHOANNO = DMTK.KHOA left join DM_LOAITIEN DMLT on TUCT.KHOALOAITIEN = DMLT.MA where TUCT.KHOATAMUNG = '" + strKhoa + "' ";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM GL_TamUngNhaCungCapChiTiet WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTamUng = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanNo = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienGhiSo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienThuc = Conversions.ToDouble(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienThucGhiSo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetDecimal));
                    this.mDienGiaiViet = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mDienGiaiAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongNo = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanCo = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongCo = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x11];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaTamUng", DbType.Int64, ParameterDirection.Input, this.mKhoaTamUng);
                commandParameters[2] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[3] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[4] = DBHelper.createParameter("@KhoaTaiKhoanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanNo);
                commandParameters[5] = DBHelper.createParameter("@KhoaLoaiTien", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiTien);
                commandParameters[6] = DBHelper.createParameter("@TyGia", DbType.Date, ParameterDirection.Input, this.mTyGia);
                commandParameters[7] = DBHelper.createParameter("@SoTien", DbType.Date, ParameterDirection.Input, this.mSoTien);
                commandParameters[8] = DBHelper.createParameter("@SoTienGhiSo", DbType.Date, ParameterDirection.Input, this.mSoTienGhiSo);
                commandParameters[9] = DBHelper.createParameter("@SoTienThuc", DbType.Date, ParameterDirection.Input, this.mSoTienThuc);
                commandParameters[10] = DBHelper.createParameter("@SoTienThucGhiSo", DbType.Date, ParameterDirection.Input, this.mSoTienThucGhiSo);
                commandParameters[11] = DBHelper.createParameter("@DienGiaiViet", DbType.Int64, ParameterDirection.Input, this.mDienGiaiViet);
                commandParameters[12] = DBHelper.createParameter("@DienGiaiAnh", DbType.Int64, ParameterDirection.Input, this.mDienGiaiAnh);
                commandParameters[13] = DBHelper.createParameter("@KhoaDoiTuongNo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongNo);
                commandParameters[14] = DBHelper.createParameter("@KhoaTaiKhoanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanCo);
                commandParameters[15] = DBHelper.createParameter("@KhoaDoiTuongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongCo);
                commandParameters[0x10] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_TamUngNhaCungCapChiTiet", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string DienGiaiAnh
        {
            get
            {
                return this.mDienGiaiAnh;
            }
            set
            {
                this.mDienGiaiAnh = value;
            }
        }

        public string DienGiaiViet
        {
            get
            {
                return this.mDienGiaiViet;
            }
            set
            {
                this.mDienGiaiViet = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDoiTuongCo
        {
            get
            {
                return this.mKhoaDoiTuongCo;
            }
            set
            {
                this.mKhoaDoiTuongCo = value;
            }
        }

        public string KhoaDoiTuongNo
        {
            get
            {
                return this.mKhoaDoiTuongNo;
            }
            set
            {
                this.mKhoaDoiTuongNo = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaLoaiTien
        {
            get
            {
                return this.mKhoaLoaiTien;
            }
            set
            {
                this.mKhoaLoaiTien = value;
            }
        }

        public string KhoaTaiKhoanCo
        {
            get
            {
                return this.mKhoaTaiKhoanCo;
            }
            set
            {
                this.mKhoaTaiKhoanCo = value;
            }
        }

        public string KhoaTaiKhoanNo
        {
            get
            {
                return this.mKhoaTaiKhoanNo;
            }
            set
            {
                this.mKhoaTaiKhoanNo = value;
            }
        }

        public string KhoaTamUng
        {
            get
            {
                return this.mKhoaTamUng;
            }
            set
            {
                this.mKhoaTamUng = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public double SoTien
        {
            get
            {
                return this.mSoTien;
            }
            set
            {
                this.mSoTien = value;
            }
        }

        public double SoTienGhiSo
        {
            get
            {
                return this.mSoTienGhiSo;
            }
            set
            {
                this.mSoTienGhiSo = value;
            }
        }

        public double SoTienThuc
        {
            get
            {
                return this.mSoTienThuc;
            }
            set
            {
                this.mSoTienThuc = value;
            }
        }

        public double SoTienThucGhiSo
        {
            get
            {
                return this.mSoTienThucGhiSo;
            }
            set
            {
                this.mSoTienThucGhiSo = value;
            }
        }

        public double TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }
    }
}

